//
//  UIViewController+Swizzling.m
//  YiCollectionView
//
//  Created by mac on 16/6/3.
//  Copyright © 2016年 Yi. All rights reserved.
//

#import "UIViewController+Swizzling.h"
static NSString const *defautStatusBarStyleController =
@"FirstViewController|SecondViewController|ThirdViewController|ViewController";


@implementation UIViewController (Swizzling)
+ (void)load {
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        Class class = [self class];
        
        SEL originalSelector = @selector(viewWillAppear:);
        SEL swizzledSelector = @selector(swizzled_viewWillAppear:);
        
        Method originalMethod = class_getInstanceMethod(class, originalSelector);
        Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);
        
        BOOL didAddMethod = class_addMethod(
                                            class, originalSelector, method_getImplementation(swizzledMethod),
                                            method_getTypeEncoding(swizzledMethod));
        
        if (didAddMethod) {
            class_replaceMethod(class, swizzledSelector,
                                method_getImplementation(originalMethod),
                                method_getTypeEncoding(originalMethod));
        } else {
            method_exchangeImplementations(originalMethod, swizzledMethod);
        }
    });
}

- (void)swizzled_viewWillAppear:(BOOL)animated {
    [self swizzled_viewWillAppear:animated];
  
    NSString *current = [NSString stringWithFormat:@"%@", [self class]];
    NSLog(@"current:%@",current);
    
}
@end
